import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue()],
  resolve: {
    // 设置路径别名
    alias: {
      "@": path.resolve(__dirname, "src"),
    },
  },

  css: {
    preprocessorOptions: {
      // 全局引入混入样式(就不用每一个scss都得引入一遍)
      scss: {
        additionalData: '@import "./src/style/minx.scss";',
      },
    },
  },

  server: {
    host: "127.0.0.1",
    open: true,
    cors: true,
    // Load proxy configuration from .env.development
    proxy: {
      "/api": {
        target: "http://127.0.0.1", //不打包
        // target: "",//打包的
        changeOrigin: true,
        rewrite: (a) => a.replace(/^\/api/, "api"), //不打包
        // rewrite: (a) => a.replace(/^\/api/, ""),//打包的
      },
      "/user": {
        target: "http://127.0.0.1",
        // target: "",//打包的
        // changeOrigin: true,
        rewrite: (a) => a.replace(/^\/user/, "user"), //不打包
        // rewrite: (a) => a.replace(/^\/user/, ""),//打包
      },
    },
  },
});
